/*
 * RawMediaWriter.h
 *
 *  Created on: 2017年3月5日
 *      Author: chuanjiang.zh
 */

#ifndef RAWMEDIAWRITER_H_
#define RAWMEDIAWRITER_H_

#include "MediaWriter.h"
#include <stdio.h>


namespace av
{

class RawMediaWriter: public MediaWriter
{
public:
	RawMediaWriter();
	virtual ~RawMediaWriter();

	virtual bool open(const char* filename, const MFormat& fmt);

	virtual void close();

	virtual bool isOpen();

	virtual bool getFormat(MFormat& fmt);

    virtual bool writeVideo(uint8_t* data, int size, int64_t pts, int flags);

    virtual bool writeAudio(uint8_t* data, int size, int64_t pts, int flags);

    virtual int getDuration();

    virtual int64_t getByteLength();

    virtual bool setFile(const char* filepath);

    virtual bool setOutputAudioCodec(int codecId);

	virtual void setListener(MediaWriterListener* listener);

	virtual bool setMeta(const char* key, const char* value, int size);

protected:
	void fireStatus(int status);

protected:
    FILE*	m_file;
    int64_t	m_totalBytes;
    MFormat	m_format;

    int64_t	m_startPts;
    int64_t	m_curPts;

	MediaWriterListener*	m_listener;

};


} /* namespace av */

#endif /* RAWMEDIAWRITER_H_ */
